// 16位密钥
const KEY = CryptoJS.enc.Utf8.parse("385f33cb91484b04a177828829081ab7");
// 16位偏移量
const IV = CryptoJS.enc.Utf8.parse("37fa77f6a3b0462d");

/*
* 加密
*/
function encrypt(data) {
    const encryptedContent = CryptoJS.AES.encrypt(data, KEY, {
        iv: IV,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    })
    const encStr = encryptedContent.ciphertext.toString();
    return encStr;
}

/**
 * 解密
 */
function decrypt(data) {
    const decryptedContent = CryptoJS.AES.decrypt(CryptoJS.format.Hex.parse(data), KEY, {
        iv: IV,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    })
    const decStr = CryptoJS.enc.Utf8.stringify(decryptedContent);
    return decStr;
}